<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    /* 定义全局变量，正方形的宽高为 */
    :root {
        --w: 100px;
    }

    .container {
        width: calc(var(--w) * 4);
        height: calc(var(--w) * 4);
        padding: var(--w);
        border-radius: calc(var(--w) /2);
        display: flex;
        flex-wrap: wrap;
        align-content: center;
        justify-content: center;
        box-shadow: 0 12px 20px 6px rgba(104, 112, 118, 0.2);
        transform-style: preserve-3d;
        transform: translate(-50%, -50%) rotateX(45deg) rotateZ(45deg);
        position: absolute;
        top: 50%;
        left: 50%;


    }

    .square {
        width: var(--w);
        height: var(--w);
        border: 1px solid red;
        background: rgba(207, 52, 40);
        position: relative;
        transform-style: preserve-3d;
        transform: translateZ(var(--w));
        box-shadow: calc(var(--w) * 3) calc(var(--w) *3) 15px rgba(0, 0, 0, 0.2);
        animation: beating 1s infinite;
        animation-delay: calc(var(--d) *0.05s);
    }

    @keyframes beating {
        50% {
            transform: translateZ(calc(var(--w) /2));
        }

    }

    .square::before {
        content: "";
        position: absolute;
        width: var(--w);
        height: var(--w);
        top: 0;
        left: 0;
        background: rgb(225 83 83);
        transform: rotateY(-90deg);
        transform-origin: right center;
    }

    .square::after {
        content: "";
        position: absolute;
        width: var(--w);
        height: var(--w);
        top: 0;
        left: 0;
        background: rgb(225 83 83);
        filter: brightness(2.1);
        transform: rotateX(90deg);
        transform-origin: right bottom;

    }

    .square:hover {
        cursor: pointer;
        filter: brightness(2.1);
        animation-play-state: paused;
    }
</style>

<body>
    <div class="container">
        <div class="square" style="--d: 1"></div>
        <div class="square" style="--d: 2"></div>
        <div class="square" style="--d: 3"></div>
        <div class="square" style="--d: 4"></div>
        <div class="square" style="--d: 5"></div>
        <div class="square" style="--d: 6"></div>
        <div class="square" style="--d: 7"></div>
        <div class="square" style="--d: 8"></div>
        <div class="square" style="--d: 9"></div>
    </div>

</body>

</html>